// 用于组件的交流中间件
const state = {
    clickUpload: true,  // 点击的时候，让选项区域的按钮改变状态,

    clickHistory: true,   // 点击历史，开始弹窗
    clickEachHistory: true,  // 刚开始点击某个历史的时候开启下载
    historyToken: '',  // 历史的upload token
    historyImage: ''  // 先到字符，否则vue无法监听
}

const mutations = {
    SET_CLICK_UPLOAD: (state, uploadState) => {
        state.clickUpload = uploadState
    },
    SET_CLICK_HISTORY: (state, historyState) => {
        state.clickHistory = historyState
    },
    SET_HISTORY_TOKEN: (state, historyToken) => {
        state.historyToken = historyToken
    },
    SET_HISTORY_IMAGE: (state, historyImage) => {
        state.historyImage = historyImage
    },
    SET_CLICK_EACH_HISTORY: (state, clickEachHistory) => {
        state.clickEachHistory = clickEachHistory
    }
}

const actions = {
    setClickUpload({ commit }, value) {
        commit('SET_CLICK_UPLOAD', value)
    },
    setClickHistory({ commit }, value){
        commit('SET_CLICK_HISTORY', value)
    },
    setHistoryToken({ commit }, value){
        commit('SET_HISTORY_TOKEN', value)
    },
    setHistoryImage({ commit }, value){
        commit('SET_HISTORY_IMAGE', value)
    },
    setClickEachHistory({ commit }, value){
        commit('SET_CLICK_EACH_HISTORY', value)
    }
}

export default {
    namespaced: true,
    state,
    mutations,
    actions
}
